package com.aerozhonghuan.logisticsmall.modules.order.logic;

import com.aerozhonghuan.logisticsmall.modules.order.base.OrderState;
import com.aerozhonghuan.logisticsmall.modules.order.beans.CancelledState;
import com.aerozhonghuan.logisticsmall.modules.order.beans.CompletedState;
import com.aerozhonghuan.logisticsmall.modules.order.beans.WaitConfirmState;
import com.aerozhonghuan.logisticsmall.modules.order.beans.WaitReviewState;
import com.aerozhonghuan.logisticsmall.modules.order.beans.WaitServiceState;

import java.util.ArrayList;
import java.util.List;

/**
 * 描述 订单状态管理类
 * @author zhangyonghui
 * 创建日期 2019-05-25
 */
public class OrderStateControl {
    public static List<OrderState> orderStates = new ArrayList<>();

    static {
        orderStates.add(new WaitReviewState());
        orderStates.add(new WaitServiceState());
        orderStates.add(new WaitConfirmState());
        orderStates.add(new CompletedState());
        orderStates.add(new CancelledState());
    }

    public static OrderState getOrderStateByCode(int status) {
        for (OrderState orderState :
                orderStates) {
            if (orderState.status == status) {
                return orderState;
            }
        }
        return null;
    }
}
